package com.asiainfo.hybridapp.utils;

import android.content.Context;
import android.content.Intent;

import com.asiainfo.hybridapp.R;
import com.asiainfo.hybridapp.activity.BaseActivity;
import com.asiainfo.hybridapp.activity.LoginWebViewActivity;
import com.asiainfo.hybridapp.configs.ConstantsME;
import com.asiainfo.hybridapp.configs.RealInterfaceConfig;
import com.framework.utils.PreferencesHelper;

public class PrestrainHTML5Util {
    private static volatile PrestrainHTML5Util singleton;

    private PrestrainHTML5Util() {
    }

    public static PrestrainHTML5Util getInstance() {
        if (singleton == null) {
            synchronized (PrestrainHTML5Util.class) {
                if (singleton == null) {
                    singleton = new PrestrainHTML5Util();
                }
            }
        }
        return singleton;
    }

    public void gotoLogin(Context context) {
        PreferencesHelper.getInstance().putInfo(ConstantsME.cookies, "");
        Intent intent =
                new Intent(context, LoginWebViewActivity.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.putExtra(ConstantsME.url, RealInterfaceConfig.getRealBaseServerUrl());
        context.startActivity(intent);
        ((BaseActivity) context).overridePendingTransition(R.anim.slide_right_in,
                R.anim.slide_left_out);
    }
}
